$(function() {

    //begin列表信息
    $("#curriculumSeries_datagrid").datagrid({
        url: "/curriculumSeries/list",
        columns: [[
            {field: "xxx", checkbox: 'true'},
            {field: "id", title: "编号", width: 100,hidden:true},
            {field: "name", title: "科目名称", width: 100},
            {field: "sort", title: "序号", width: 100,sortable:true,order:'desc'}
        ]],
        fit: true,
        fitColumns: true,
        pagination: true,
        rownumbers: true,
        singleSelect: true,
        striped: true,
        pageNumber:1,
        pageSize:3,
        pageList:[3,5,10,20],
        toolbar: "#curriculumSeries_tb"
    });
    //end列表信息

    //begin添加/编辑对话框
    $("#curriculumSeries_dialog").dialog({
        width: 300,
        height: 200,
        buttons: "#curriculumSeries_bb",
        closed: true
    });
    //end添加/编辑对话框

    //begin处理功能方法的对象
    var obj = {
        //begin添加按钮
        add: function () {
            $("#curriculumSeries_form").form("clear");
            $("#curriculumSeries_dialog").dialog("setTitle", "课程系列添加");
            $("#curriculumSeries_dialog").dialog("open");
        },
        //end添加按钮

        //begin编辑按钮
        edit: function () {
            $("#curriculumSeries_form").form("clear");
            $("#curriculumSeries_dialog").dialog("setTitle", "课程系列编辑");
            var row = $("#curriculumSeries_datagrid").datagrid("getSelected");
            if (!row) {
                $.messager.alert('温馨提示', '请选择要操作的行!');
                return;
            }
            $("#curriculumSeries_form").form("load", row);
            $("#curriculumSeries_dialog").dialog("open");
        },
        //end编辑按钮

        //begin取消按钮
        cancel: function () {
            $("#curriculumSeries_dialog").dialog("close");
        },
        //end取消按钮

        //begin保存按钮
        save: function () {
            var curriculumSeriesId = $("#curriculumSeriesId").val();
            var url;
            if (curriculumSeriesId) {
                url = "/curriculumSeries/update"
            } else {
                url = "/curriculumSeries/save"
            }
            $("#curriculumSeries_form").form("submit", {
                url: url,
                success: function (data) {
                    var data = $.parseJSON(data);
                    if (!data.success) {
                        $.messager.alert('温馨提示', data.msg);
                    } else {
                        $.messager.alert('温馨提示', "操作成功!");
                        $("#curriculumSeries_dialog").dialog("close");
                        $("#curriculumSeries_datagrid").datagrid("reload");
                    }
                }
            });
        },
        //end保存按钮


        //begin刷新按钮
        reload:function (){
            $("#curriculumSeries_datagrid").datagrid("reload")
        }
        //end刷新按钮
    };
    //end处理功能方法的对象

    //begin处理功能方法对象,实际调用方法
    $("a[data-cmd]").click(function(){
        var cmd = $(this).data("cmd");
        obj[cmd]();
    });
    //end处理功能方法对象,实际调用方法


});